<!-- 编辑信息 -->
<template>
  <div class="all">
    <el-card>
      <strong>完善信息</strong>
      <el-descriptions class="margin-top" :column="1" style="margin-top: 20px" border>

        <el-descriptions-item>
          <template slot="label">
            <i class="el-icon-user"></i>
            真实姓名
          </template>
          <el-input v-model="realName"></el-input>
        </el-descriptions-item>

        <el-descriptions-item>
          <template slot="label">
            <i class="el-icon-mobile-phone"></i>
            性别
          </template>
          <el-select v-model="value">
            <el-option
              v-for="item in options"
              :key="item.value"
              :label="item.label"
              :value="item.value">

            </el-option>
          </el-select>
        </el-descriptions-item>

        <el-descriptions-item>
          <template slot="label">
            <i class="el-icon-edit"></i>
            专业
          </template>
          <el-select v-model="majorID">
            <el-option
              v-for="item in M_options"
              :key="item.majorID"
              :label="item.majorName"
              :value="item.majorID">

            </el-option>
          </el-select>
        </el-descriptions-item>

        <el-descriptions-item>
          <template slot="label">
            <i class="el-icon-edit"></i>
            学历
          </template>
          <el-select v-model="educationID">
            <el-option
              v-for="item in E_options"
              :key="item.educationID"
              :label="item.educationName"
              :value="item.educationID">

            </el-option>
          </el-select>
        </el-descriptions-item>

      </el-descriptions>

      <el-button type="primary" class="change-btn" @click="updateInfo">确认</el-button>
    </el-card>
  </div>
</template>

<script>
let _fileObj
export default {
  data() {
    return {
      options: [{
        value: '男',
        label: '男'
      }, {
        value: '女',
        label: '女'
      }],
      E_options:[],
      M_options:[],
      value: '',
      majorID:'',
      educationID:'',
      realName:'',
      username:'',
      dialogImageUrl: '',
      dialogVisible: false,
      disabled: false
    };
  },
  methods: {
    updateInfo(){
      this.$axios({
        url:'/api/user/update',
        method:'put',
        data:{
          Name:this.username,
          realname:this.realName,
          Gender:this.value,
          MajorID:this.majorID,
          EducationID:this.educationID,
        },
        headers:{
          Authorization:this.$cookies.get("token")
        }
      }).then(res=>{
          // console.log(res)
        if(res.data.code === 0){
          this.$message.success("更新成功")
        }else {
          this.$message.error("更新失败")
        }
      })
    },
    getEMList(){
      this.$axios({
        url:'/api/major/eduList',
        method:'get',
        headers:{
          "Authorization":this.$cookies.get("token")
        }
      }).then(res =>{
        this.E_options = res.data.data
        console.log(this.E_options)
      })
      this.$axios({
        url:'/api/major/majorList',
        method:'get',
        headers:{
          "Authorization":this.$cookies.get("token")
        }
      }).then(res =>{
        this.M_options = res.data.data
        console.log(this.M_options)
      })
    },
  },
  mounted() {
    this.username = this.$cookies.get('username')
    this.getEMList()
  }
};
</script>
<style lang="less" scoped>
.all {
  padding: 0px 40px;
  .page {
    margin-top: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
  }
  .edit {
    margin-left: 20px;
  }
  .el-table tr {
    background-color: #dd5862 !important;
  }
}
.add {
  padding: 0px 40px;
  width: 400px;
}
.change-btn{
  margin-left: 45%;
  margin-top: 20px;
  width: 100px
}
.avatar-uploader .el-upload {
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.avatar-uploader .el-upload:hover {
  border-color: #409EFF;
}
.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 178px;
  height: 178px;
  line-height: 178px;
  text-align: center;
}
.avatar {
  width: 178px;
  height: 178px;
  display: block;
}
</style>

